package com.xjk.demo.controller;

import com.xjk.demo.entity.GoodsParam;
import com.xjk.demo.entity.User;
import com.xjk.demo.service.UserService;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@Controller
@RequestMapping("/user")
public class UserController {

    @Autowired
    private UserService userService;

    @RequestMapping("/list")
    public String list(GoodsParam p, Model model){
        int count = userService.getCount(p);
        p.setPageSize(2);
        p.setTotal(count);
        List<User> uList = userService.getUserList(p);
        model.addAttribute("uList",uList);
        model.addAttribute("p",p);
        return "list";
    }

    @RequestMapping("/delAll")
    public String del(@Param("ids") String ids){

        userService.delAll(ids);
        return "redirect:/user/list";

    }
}
